<?php
/*
 *author:Yangligao
 *Date:2013-10-3
 */
require 'Config.php';
require 'Public/Include/adv.php';
require 'Public/Include/footer.php';
require 'Public/Include/search.php';
require 'Public/Include/HotSort.php';
require 'Public/Include/latest.php';
$flag = isset($_GET['flag'])?$_GET['flag']:'儿童食品';

$foodModel = new FoodModel();

if($flag == 3){
	$smarty->assign('positionFlag',"儿童商品列表");
	$Count = $foodModel->food_select("count(*) as num","where food_type=3");
	
	$pageSize = 6;
	$totalCount = $Count[0]['num'];
	$pageModel = new Page($pageSize, $totalCount);
	$start = $pageModel->getStart();
	$res = $foodModel->food_select("*","where food_type=3","limit {$start},$pageSize","order by food_producttime desc");
	
	$pageStr = $pageModel->getPageStr();
	
	$smarty->assign('pageStr',$pageStr);
	for ($i=0;$i<count($res); $i++){
		$res[$i]['food_content'] = mb_substr($res[$i]['food_content'], 0,80,"utf-8")."...";
	}
	$smarty->assign('res',$res);
	
}else if($flag == 1){
	$smarty->assign('positionFlag',"节令商品列表");
	
	$Count = $foodModel->food_select("count(*) as num","where food_type=1");
	
	$pageSize = 6;
	$totalCount = $Count[0]['num'];
	$pageModel = new Page($pageSize, $totalCount);
	$start = $pageModel->getStart();
	$res = $foodModel->food_select("*","where food_type=1","limit {$start},$pageSize","order by food_producttime desc");
	
	$pageStr = $pageModel->getPageStr();
	
	$smarty->assign('pageStr',$pageStr);
	for ($i=0;$i<count($res); $i++){
		$res[$i]['food_content'] = mb_substr($res[$i]['food_content'], 0,80,"utf-8")."...";
	}
	$smarty->assign('res',$res);
	
}else if($flag == 2){
	$smarty->assign('positionFlag',"四季商品列表");
	$Count = $foodModel->food_select("count(*) as num","where food_type=2");
	
	$pageSize = 6;
	$totalCount = $Count[0]['num'];
	$pageModel = new Page($pageSize, $totalCount);
	$start = $pageModel->getStart();
	$res = $foodModel->food_select("*","where food_type=2","limit {$start},$pageSize","order by food_producttime desc");
	
	$pageStr = $pageModel->getPageStr();
	
	$smarty->assign('pageStr',$pageStr);
	for ($i=0;$i<count($res); $i++){
		$res[$i]['food_content'] = mb_substr($res[$i]['food_content'], 0,80,"utf-8")."...";
	}
	$smarty->assign('res',$res);
}


$smarty->display('Index/foodlist.html');
?>
